import { findCinemas } from '@/api/MaiZuo';

const clearCinemaList = () => {
  return { type: 'clear-cinemaList' };
};

// // reduce-thunk
// const getCinemaList = (cityId = 110100) => {
//   return (dispatch) => {
//     findCinemas(cityId).then((res) => {
//       dispatch({
//         type: 'change-cinemaList',
//         payload: res.cinemas || [],
//       });
//     });
//   };
// };

// redux-promise
const getCinemaList = async (cityId = 110100) => {
  const res = await findCinemas(cityId);
  return {
    type: 'change-cinemaList',
    payload: res.cinemas || [],
  };
};

export { clearCinemaList, getCinemaList };
